<template>
  <div class="content content42">
    <div class="innertitle">
      1.共振频率：
    </div>
    <div style="margin-left: 30px;">
      <div>开机后：<el-input v-model="form.resonanceFrequency.afterStartup" class="input-line" />关机前：<el-input v-model="form.resonanceFrequency.beforeStartup" class="input-line" /></div>
      <div>偏  差：<el-input v-model="form.resonanceFrequency.deviation" class="input-line" />%   </div>
    </div>
    <div class="innertitle">
      2.影像均匀性：
    </div>
    <table border="1" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td colspan="2">检测参数</td>
        <td :colspan="imageUniformity.table.td+2">检测记录</td>
      </tr>
      <tr>
        <td colspan="2" rowspan="2">ROI</td>
        <td rowspan="2" v-for="index in imageUniformity.table.td" :key="index">{{index}}</td>
        <td colspan="2">像素平均值</td>
      </tr>
      <tr>
        <td>S<span class="miniFont">max</span></td>
        <td>S<span class="miniFont">min</span></td>
      </tr>
      <tr v-for="index in imageUniformity.table.tr" :key="index">
        <td style="min-width: 100px;">mm层厚</td>
        <td>S</td>
        <td v-for="tdIndex in imageUniformity.table.td" :key="tdIndex">
          <el-input v-model="form.imageUniformity['thickness_'+index+'_'+tdIndex]" class="input-line" />
        </td>
        <td>
          <el-input v-model="form.imageUniformity['pixelAverageMax_'+index]" class="input-line" />
        </td>
        <td>
          <el-input v-model="form.imageUniformity['pixelAverageMin_'+index]" class="input-line" />
        </td>
      </tr>
      <tr>
        <td colspan="2">影像均匀性</td>
        <td :colspan="imageUniformity.table.td+2" class="multipleInput">U(％)＝｛1－(S<span class="miniFont">max</span>-S<span class="miniFont">min</span>)/(S<span class="miniFont">max</span>+ S<span class="miniFont">min</span>)｝×100％＝<el-input v-model="form.imageUniformity.uniformity" class="input-line" />%</td>
      </tr>
    </table>
    <div class="innertitle">
      3.信噪比SNR
    </div>
    <table border="1" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td rowspan="2">层厚/mm</td>
        <td colspan="2">影像中心区域</td>
        <td :colspan="signalNoiseRatio.table.td">背景区域本底测量信号 S<span class="miniFont">本</span> ± SD<span class="miniFont">本</span></td>
        <td rowspan="2">平均值S<span class="miniFont">b平均</span></td>
      </tr>
      <tr>
        <td>S<span class="miniFont">mean</span></td>
        <td>噪声SD</td>
        <td v-for="index in signalNoiseRatio.table.td" :key="index">{{index}}</td>
      </tr>
      <tr v-for="index in signalNoiseRatio.table.tr" :key="index">
        <td>
          <el-input v-model="form.signalNoiseRatio['thickness_'+index]" class="input-line" />
        </td>
        <td>
          <el-input v-model="form.signalNoiseRatio['smean_'+index]" class="input-line" />
        </td>
        <td>
          <el-input v-model="form.signalNoiseRatio['noise_'+index]" class="input-line" />
        </td>
        <td v-for="tdIndex in signalNoiseRatio.table.td" :key="tdIndex">
          <el-input v-model="form.signalNoiseRatio['background_'+index+'_'+tdIndex]" class="input-line" />
        </td>
        <td>
          <el-input v-model="form.signalNoiseRatio['average_'+index]" class="input-line" />
        </td>
      </tr>
      <tr>
        <td>信噪比（SNR）</td>
        <td :colspan="signalNoiseRatio.table.td+3" class="multipleInput">SNR＝（S<span class="miniFont">mean</span>－S<span class="miniFont">b平均</span>）/SD＝<el-input v-model="form.signalNoiseRatio.snr" class="input-line" /></td>
      </tr>
    </table>
    <div class="innertitle">
      4.高对比空间分辨力：
    </div>
    <table border="1" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td >成像平面</td>
        <td >采集矩阵</td>
        <td v-for="(item,index) in contrastResolutionHigh.table" :key="index">{{item}}×{{item}}</td>
      </tr>
      <tr>
        <td rowspan="2">mm层厚</td>
        <td>测量值/（lp/cm）</td>
        <td v-for="(item,index) in contrastResolutionHigh.table" :key="index">
          <el-input v-model="form.contrastResolutionHigh['measuredValue_'+(index+1)]" class="input-line" />
        </td>
      </tr>
      <tr>
        <td>空间分辨力/（mm）</td>
        <td v-for="(item,index) in contrastResolutionHigh.table" :key="index">
          <el-input v-model="form.contrastResolutionHigh['spatialResolution_'+(index+1)]" class="input-line" />
        </td>
      </tr>
    </table>
    <div class="innertitle">
      5.层厚：
    </div>
    <table border="1" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td >位置</td>
        <td v-for="(item,index) in thickness.table.item" :key="index">{{item}}点位置(mm)</td>
        <td>层厚误差δ<span class="miniFont">max</span>(mm)</td>
      </tr>
      <tbody v-for="tbIndex in thickness.table.tr" :key="tbIndex">
        <tr>
          <td>层厚标称值</td>
          <td :colspan="thickness.table.item.length"><el-input v-model="form.thickness['layerThicknessNominalValue_'+tbIndex]" class="input-line" /></td>
          <td rowspan="6"><el-input v-model="form.thickness['error_'+tbIndex]" class="input-line" /></td>
        </tr>
        <tr>
          <td>WL<span class="miniFont">BG</span></td>
          <td v-for="(item,index) in thickness.table.item" :key="index">
            <el-input v-model="form.thickness['wlbg_'+tbIndex+'_'+item]" class="input-line" />
          </td>
        </tr>
        <tr>
          <td>WL<span class="miniFont">max</span></td>
          <td v-for="(item,index) in thickness.table.item" :key="index">
            <el-input v-model="form.thickness['wlmax_'+tbIndex+'_'+item]" class="input-line" />
          </td>
        </tr>
        <tr>
          <td>FWHM</td>
          <td v-for="(item,index) in thickness.table.item" :key="index">
            <el-input v-model="form.thickness['fwhm_'+tbIndex+'_'+item]" class="input-line" />
          </td>
        </tr>
        <tr>
          <td>测量值L/（mm）</td>
          <td v-for="(item,index) in thickness.table.item" :key="index">
            <el-input v-model="form.thickness['measuredValue_'+tbIndex+'_'+item]" class="input-line" />
          </td>
        </tr>
        <tr>
          <td >平均值<span style="text-decoration: overline;">L</span>/（mm）</td>
          <td  style="transform: scaleX(150%) translateX(16.5%);">
            <el-input style="transform: scaleX(70%);" v-model="form.thickness['average_'+tbIndex]" class="input-line" />
          </td>
          <td style="transform: translateX(49%);">修正值（mm）</td>
          <td colspan="1.5" style="transform: scaleX(152%) translateX(49%);">
            <el-input style="transform: scaleX(70%);"   v-model="form.thickness['correctedValue_'+tbIndex]" class="input-line" />
          </td>
        </tr>
      </tbody>
    </table>
    <div class="latex">
    	<i>$层厚=FWHM \times tan \phi$</i>
    </div>
    <div class="innertitle">
      6.层厚非均匀性
    </div>
    <table border="1" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td rowspan="2">设置层厚/mm</td>
        <td :colspan="thicknessNonUniform.table.td">测量层厚/mm</td>
        <td >结果</td>
      </tr>
      <tr>
        <td v-for="index in thicknessNonUniform.table.td" :key="index">{{index}}</td>
        <td>
        	标准偏差%
        </td>
      </tr>
      <tr>
        <td>
          <el-input v-model="form.thicknessNonUniform.setThickness" class="input-line" />
        </td>
        <td v-for="index in thicknessNonUniform.table.td" :key="index">
          <el-input v-model="form.thicknessNonUniform['measureThickness_'+index]" class="input-line" />
        </td>
        <td>
          <el-input v-model="form.thicknessNonUniform.standardDeviation" class="input-line" />
        </td>
      </tr>
    </table>
    <div class="innertitle">
      7.几何畸变率：
    </div>
    <table border="1" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td>线段</td>
        <td>实际模体尺寸LA /cm</td>
        <td>影像测量尺寸LM /cm</td>
        <td>绝对值差│LA-LM│</td>
        <td>百分偏差％(│LA-LM│/LA)×100</td>
      </tr>
      <tr v-for="(item,index) in geometricDistortionRate.table.tr" :key="index">
        <td>{{item}}</td>
        <td><el-input v-model="form.geometricDistortionRate['reality'+item]" class="input-line" /></td>
        <td><el-input v-model="form.geometricDistortionRate['measure'+item]" class="input-line" /></td>
        <td><el-input v-model="form.geometricDistortionRate['absoluteDifference'+item]" class="input-line" /></td>
        <td><el-input v-model="form.geometricDistortionRate['deviation'+item]" class="input-line" /></td>
      </tr>
      <tr>
      <td colspan="5" class="multipleInput">
        最大影像几何畸变率GD%=<el-input v-model="form.geometricDistortionRate.geometricDistortionRate" class="input-line" />
      </td>
      </tr>
    </table>
    <div class="innertitle">
      8.纵横比
    </div>
    <table border="1" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td class="bias"></td>
        <td>AB(cm)</td>
        <td>CD(cm)</td>
        <td>纵横比</td>
        <td>偏差(%)</td>
      </tr>
      <tr>
        <td>实际成像体</td>
        <td><el-input v-model="form.aspectRatio.actualImagingVolumeAB" class="input-line" /></td>
        <td><el-input v-model="form.aspectRatio.actualImagingVolumeCD" class="input-line" /></td>
        <td><el-input v-model="form.aspectRatio.actualImagingVolumeAspectRatio" class="input-line" /></td>
        <td class="multipleInput" style="transform: scaleY(150%) translateY(17%);">
          <div style="transform: scaleY(70%);">
            a=<el-input v-model="form.aspectRatio.actualImagingVolumeDeviation" class="input-line" />
          </div>
        </td>
      </tr>
      <tr>
        <td>视频显示系统影像</td>
        <td><el-input v-model="form.aspectRatio.videoImagingVolumeAB" class="input-line" /></td>
        <td><el-input v-model="form.aspectRatio.videoImagingVolumeCD" class="input-line" /></td>
        <td><el-input v-model="form.aspectRatio.videoImagingVolumeAspectRatio" class="input-line" /></td>
        <td class="multipleInput" style= "transform: scaleY(158%) translateY(46%);">
          <div style="transform: scaleY(70%);">
            c=<el-input v-model="form.aspectRatio.videoImagingVolumeDeviation" class="input-line" />
          </div>
        </td>
      </tr>
      <tr>
        <td>硬拷贝系统影像</td>
        <td><el-input v-model="form.aspectRatio.copyImagingVolumeAB" class="input-line" /></td>
        <td><el-input v-model="form.aspectRatio.copyImagingVolumeCD" class="input-line" /></td>
        <td><el-input v-model="form.aspectRatio.copyImagingVolumeAspectRatio" class="input-line" /></td>
      </tr>
      <tr>
        <td>视频显示系统影像与实际成像体偏差(a、b中较大值)</td>
        <td colspan="4">
          <el-input v-model="form.aspectRatio.maxDeviation" class="input-line" />
        </td>
      </tr>
    </table>
    <div class="innertitle">
      9.静磁场（B<span class="miniFont">0</span>）均匀度和静磁场（B<span class="miniFont">0</span>）非稳定性
    </div>
    <div>
      FOV≥380mm×380mm
    </div>
    <div>
      影像上格栅是否均匀对称：<el-radio v-model="form.staticMagneticField.symmetry" :label="true">是</el-radio><el-radio v-model="form.staticMagneticField.symmetry" :label="false">否</el-radio>
    </div>
    <div>
      超导磁体:
    </div>
    <table border="1" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td :colspan="staticMagneticField.table.td">共振中心频率</td>
        <td rowspan="2">时间间隔，h</td>
        <td rowspan="2">非稳定性，10<span class="miniFont" style="transform: translateY(-5px);display: inline-block;">-6</span>/h</td>
      </tr>
      <tr>
        <td v-for="index in staticMagneticField.table.td" :key="index">f<span class="miniFont">{{index}}</span></td>
      </tr>
      <tr>
        <td v-for="index in staticMagneticField.table.td" :key="index">
          <el-input v-model="form.staticMagneticField['frequency_'+index]" class="input-line" />
        </td>
        <td>
          <el-input v-model="form.staticMagneticField.timeInterval" class="input-line" />
        </td>
        <td>
          <el-input v-model="form.staticMagneticField.instability" class="input-line" />
        </td>
      </tr>
    </table>
    <img src="@/assets/images/test_item42/form9_formula.png" alt="">
    <div class="innertitle">
      10.永磁体和常导磁体:
    </div>
    <table border="1" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td>共振中心频率f</td>
        <td v-for="index in magnet.table.td" :key="index">
          <el-input v-model="form.magnet['frequency_'+index]" class="input-line" />
        </td>
      </tr>
      <tr>
        <td>f<span class="miniFont">max</span></td>
        <td :colspan="(magnet.table.td+1)/3-1">
          <el-input v-model="form.magnet.maxFrequency" class="input-line" />
        </td>
        <td>f<span class="miniFont">min</span></td>
        <td :colspan="(magnet.table.td+1)/3-1">
          <el-input v-model="form.magnet.minFrequency" class="input-line" />
        </td>
        <td>平均值</td>
        <td :colspan="(magnet.table.td+1)/3-1">
          <el-input v-model="form.magnet.averageAalue" class="input-line" />
        </td>
      </tr>
      <tr>
        <td>t，h</td>
        <td :colspan="magnet.table.td">
          <el-input v-model="form.magnet.timeInterval" class="input-line" />
        </td>
      </tr>
      <tr>
        <td>非稳定性10<span class="miniFont" style="transform: translateY(-5px);display: inline-block;">-6</span>/h</td>
        <td :colspan="magnet.table.td">
          <el-input v-model="form.magnet.instability" class="input-line" />
        </td>
      </tr>
    </table>
    <img src="@/assets/images/test_item42/form10_formula.png" alt="">
    <div class="innertitle">
      11.影像伪影
    </div>
    <table border="1" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td>实际影像信号值T</td>
        <td>伪影信号值G</td>
        <td>误差E，%</td>
      </tr>
      <tr>
        <td><el-input v-model="form.imageArtifact.actualImage" class="input-line" /></td>
        <td><el-input v-model="form.imageArtifact.artifact" class="input-line" /></td>
        <td><el-input v-model="form.imageArtifact.error" class="input-line" /></td>
      </tr>
    </table>
    <img src="@/assets/images/test_item42/form11_formula.png" alt="">
    <div class="innertitle">
      12.制冷剂（液氮、液氦）挥发率
    </div>
    <table border="1" cellspacing="0" cellpadding="0" align="center">
      <tr>
        <td>制冷剂消耗量</td>
        <td>上次注入时间</td>
        <td>本次注入时间</td>
        <td>挥发率</td>
      </tr>
      <tr>
        <td><el-input v-model="form.volatilizationRate.consumption" class="input-line" /></td>
        <td><el-input v-model="form.volatilizationRate.lastTime" class="input-line" /></td>
        <td><el-input v-model="form.volatilizationRate.thisTime" class="input-line" /></td>
        <td><el-input v-model="form.volatilizationRate.volatilizationRate" class="input-line" /></td>
      </tr>
    </table>
    <div>
      厂家规定值：<el-input v-model="form.volatilizationRate.manufactorValue" class="input-line" />
    </div>
  </div>
</template>

<script>
  import {getInfoById42, postInfo} from '@/api/testItem/item42'
  export default{
    name:'testItem42',
    data(){
      return{
        magnet:{
          table:{
            td:8
          },
          action:'magnet',
          flag:true,
          loading:false
        },
        staticMagneticField:{
          table:{
            td:2
          },
          action:'magneticField',
          flag:true,
          loading:false
        },
        geometricDistortionRate:{
          table:{
            tr:['AB','BC','DE','EF','GH','HI']
          },
          action:'distortionRate',
          flag:true,
          loading:false
        },
        thicknessNonUniform:{
          table:{
            td:4
          },
          action:'nonUniform',
          flag:true,
          loading:false
        },
        thickness:{
          table:{
            tr:5,
            item:['0','3','6','9']
          },
          action:'thickness',
          flag:true,
          loading:false
        },
        imageUniformity:{
          table:{
            tr:2,
            td:9
          },
          action:'imageUniformity',
          flag:true,
          loading:false
        },
        signalNoiseRatio:{
          table:{
            tr:2,
            td:4
          },
          action:'signalNoiseRatio',
          flag:true,
          loading:false
        },
        contrastResolutionHigh:{
          table:[
            '128','256','512'
          ],
          action:'resolutionHigh',
          flag:true,
          loading:false
        },
        "resonanceFrequency": {
          action:'resonanceFrequency',
          flag:true,
          loading:false
        },
        "aspectRatio": {
          action:'aspectRatio',
          flag:true,
          loading:false
        },
        "imageArtifact": {
          action:'imageArtifact',
          flag:true,
          loading:false
        },
        "volatilizationRate": {
          action:'volatilizationRate',
          flag:true,
          loading:false
        },
        "form": {
          "itemsId": 0,
          "resultId": 0,
          "resonanceFrequency": {
          },
          "imageUniformity": {
          },
          "signalNoiseRatio": {
          },
          "contrastResolutionHigh": {
          },
          "thickness": {
          },
          "geometricDistortionRate": {
          },
          "aspectRatio": {
          },
          "staticMagneticField": {
          },
          "magnet": {
          },
          "imageArtifact": {
          },
          "volatilizationRate": {
          },
          "thicknessNonUniform":{

          }
        }
      }
    },
    props: {
    	// tab栏
      activeNameEquipment: {
    		type: String,
        default: "0",
      },
    	// 基本信息数据
      basicForm: {
    		type: Object,
        default: () => {
    			return {}
    		},
      },
    },
    watch:{
      activeNameEquipment: {
        handler(val) {
          this.$nextTick(()=>{
            let resultId = this.basicForm.resultId;
            // if (this.basicForm.protectionDetectionVo?.taskDetectionEquipmentResultId) {
            // 	resultId = this.basicForm.protectionDetectionVo.taskDetectionEquipmentResultId;
            // }
            getInfoById42(resultId).then(response => {
              if(response.code == 200){
                let data = response.data;
                for(let keys in data){
                  this.form[keys] = data[keys] || {};
                }
              }
            }).catch((response) => {
               this.$emit("loadingchange", true);
             });
             });
        },
        deep: true,
        immediate: true
      },
      "form.resonanceFrequency":{
        handler(newName, oldName) {
          this.validateData(newName,'resonanceFrequency');
        },
        deep:true,
        immediate: true
      },
      "form.imageUniformity":{
        handler(newName, oldName) {
          this.validateData(newName,'imageUniformity');
        },
        deep:true,
        immediate: true
      },"form.signalNoiseRatio":{
        handler(newName, oldName) {
          this.validateData(newName,'signalNoiseRatio');
        },
        deep:true,
        immediate: true
      },"form.contrastResolutionHigh":{
        handler(newName, oldName) {
          this.validateData(newName,'contrastResolutionHigh');
        },
        deep:true,
        immediate: true
      },"form.thickness":{
        handler(newName, oldName) {
          this.validateData(newName,'thickness');
        },
        deep:true,
        immediate: true
      },"form.thicknessNonUniform":{
        handler(newName, oldName) {
          this.validateData(newName,'thicknessNonUniform');
        },
        deep:true,
        immediate: true
      },"form.geometricDistortionRate":{
        handler(newName, oldName) {
          this.validateData(newName,'geometricDistortionRate');
        },
        deep:true,
        immediate: true
      },"form.aspectRatio":{
        handler(newName, oldName) {
          this.validateData(newName,'aspectRatio');
        },
        deep:true,
        immediate: true
      },"form.staticMagneticField":{
        handler(newName, oldName) {
          let notNumber=['symmetry'];
          this.validateData(newName,'staticMagneticField',notNumber);
        },
        deep:true,
        immediate: true
      },"form.magnet":{
        handler(newName, oldName) {
          this.validateData(newName,'magnet');
        },
        deep:true,
        immediate: true
      },"form.imageArtifact":{
        handler(newName, oldName) {
          this.validateData(newName,'imageArtifact');
        },
        deep:true,
        immediate: true
      },"form.volatilizationRate":{
        handler(newName, oldName) {
          this.validateData(newName,'volatilizationRate');
        },
        deep:true,
        immediate: true
      }
    },
    methods:{
      //表单修改提交后端
      postForm(param,name){
        param['itemsId'] = this.form.itemsId;
        this.$emit("loadingchange", true);
        if(!this[name].loading){
          this[name].loading = true;
          postInfo(param,this[name].action).then(res=>{
            this.$emit("loadingchange", false);
            if(res.code == 200){
              this[name].flag = false;
              this[name].loading = false;
              this.$set(this.form,name,res.data);
            }
          })
        }
     },
      //数据验证
      validateData(newName,myName,notNumber=[],intNumber=[]){
        let regNumber = /^-?\d*(.(\d+))?$/;//小数验证正则
        let regRepNumber = /[^-?\d.,]/g;//将除小数外的符号消除正则
        let regInt = /^\d*$/;//整数验证正则
        let regRepInt = /[^-?\d,]/g;//将除小数外的符号消除正则
        let reg,regRep;
        let repStr = '';
        let flag = true;//是否改变this[myName].flag标识
        if(JSON.stringify(newName) != '{}'){
          //遍历该对象所有字段进行验证
          for(let keys in newName){
            reg = intNumber.indexOf(keys) != -1 ? regInt:regNumber;
            regRep = intNumber.indexOf(keys) != -1 ? regRepInt:regRepNumber;
            //数字验证环节
            if(newName[keys] && notNumber.indexOf(keys)==-1){
              let bool = !reg.test(newName[keys]);
              if(bool){
                repStr =  newName[keys].replace(regRep,'');
                newName[keys] = repStr;
                if(this[myName].flag){
                 this[myName].flag = false;//如果数字验证不通过不需要请求后端
                 if(repStr != newName[keys]){//如果字段未改变则在中过滤一次后端请求
                   flag = false;
                 }
                }
              }
            }
          }
          if(this[myName].flag){//是否请求后端判断
           let postBody = {};
           for(let i in newName){
             if((newName[i] === 0) || (newName[i] && newName[i] != '')){
               postBody[i] = newName[i];
             }
           }
           if(JSON.stringify(postBody) != '{}'){
             this.postForm(postBody,myName);
           }
          }else if(flag){
            setTimeout(()=>{
              this[myName].flag = true;
            },100);
          }
        }
      }
    }

  }
</script>

<style lang="scss" scoped>
  @import '../content.scss';

  .bias::before{
    content: "";
    position: absolute;
    width: 2px;
    height: 240px;
    top: 171;
    left: 57;
    background-color: #000;
    display: block;
    -webkit-transform: rotate(-83.5deg);
    transform: rotate(-83.5deg);
    -webkit-transform-origin: top;
    transform-origin: top;
    z-index: 2;
    border: 0;
  }
  .miniFont {
    font-size: 10px;
  }

  .miniFontCenter {
    margin-top: 8px;
  }

  .content42 {
    padding-inline: 0 !important;

    table {
      width: 100%;

      td {
        max-width: 100px;

        ::v-deep .el-checkbox__label {
          white-space: break-spaces;
        }
      }

      .el-input {
        width: 100% !important;
      }

      .multipleInput {
        .el-input {
          width: 50px !important;
        }
      }
    }

    .innertitle {
      display: block;
      margin-left: 0;
    }

    .table1 {
      .el-radio {
        display: flex;
        align-items: center;
      }
    }

    #hearderTR td:nth-child(7) {
      display: none;
    }
  }
</style>
